<?php

namespace app\web\model;

use think\Db;
use think\Model;

class ProblemModel extends Model
{

    // 设置数据表（不含前缀）
    protected $name = 'poblem_table';

    public function __construct($data = [])
    {
        parent::__construct($data);
        $this->_collection = Db::name($this->name);
    }


    /**
     * @param 获取问题列表
     */
    public function listt($where,$query){
        $list = Db::name($this->name)->alias('a')->join('adminuser b','a.FounderID=b.id')->field('a.id,a.title,a.ProblemContent,a.imgurl,a.addTime,b.username')->where($where)->order('a.addTime desc')->paginate(4,false,$query);
        $page = $list->render();
        return array("list"=>$list,"page"=>$page);
    }


    /**
     * @param 获取当前问题详情
     */
    public function pomolist($where){
        $query = Db::name($this->name)->alias('a')->where($where)->join('adminuser b','a.FounderID=b.id')->field('a.title,a.ProblemContent,a.state,a.uid,a.FounderID,a.addTime,b.username')->find();
        return $query;
    }

}